<%--
 *  File:    FavoriteMenuTree.jsp
 *  @Author: Rael Zhu
 *  Date:    Tuesday, October 21st, 2003

 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>

<%@ include file="/inc/SessionTimeout.inc"%>

<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>
<%@ page contentType = "text/html;charset=UTF-8" %>

<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  String strModuleName = "IMG";
  String privilegeCode = "Z0505";
%>

<%@include file="/inc/PageDefault.inc"%>
<%@ include file="/inc/Security.inc" %>

<html>
<head>
<title>FavoriteMenuTree</title>
<PageFlow:CheckPageFlow pageName="systemmenu"/>
<%
  Vector systemmenu = (Vector)pageContext.getAttribute("systemmenu");
  if (systemmenu == null) systemmenu = new Vector();
  Vector allapp = (Vector)pageContext.getAttribute("allapp");
  if (allapp == null) allapp = new Vector();
  Integer app = (Integer)pageContext.getAttribute("app");
  if (app == null) app = new Integer(1);
%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="../../css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="../../css/menu.js"></script>
<script language="JavaScript" src="../js/FuncLib.js"></script>
<script language="JavaScript">

function page_select()
{
  document.frm.app.value = document.frm.appid.value;
  document.frm.action = "FavoriteMenuTree.jsp?<%= OvalTools.randomURL() %>";
  document.frm.target = "_self";
  isRunning = true;
  document.frm.submit();  
}

</script>
</head>
<body>
<form name="frm" method="post" action="../../Dispatcher">
  <input type="hidden" name="pagename" value="">
  <input type="hidden" name="actionname">
  
  <input type="hidden" name="app" value="<%=JspHelper.filterNull( app )%>">
  
<table border="0" cellspacing="1" width="100%">
  <tr> 
    <td><%= label.getLabelName("L_System") + label.getLabelName("L_Colon") %><custom:select optionsName="allapp" optionValueKey="appid" optionInnerTextKey="applicationname" property="appid"/>
      <a href="javascript:page_select();"><img src="../../images/<%= strLanguageCode %>/go.gif" border="0"></a>
    </td>
  </tr>
</table>

<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center" height="88%">
  <tr> 
    <td colspan="-1" class="deepblue-left">
      <img src="../../images/<%= strLanguageCode %>/quote.gif" width="16" height="11"> 
      <%= label.getLabelName("L_Menu") + label.getLabelName("L_Colon") %>
    </td>
  </tr>
  <%
    OvalTree initTree = new OvalTree(systemmenu,"privilegeid","parentprivid","grade");
    initTree.setRecursiveLimit(2000);
    Vector menuTree = (Vector)initTree.getTreeVector(new Integer(-1000),1);
  %>
  <tr><td class="spe-td"> 
    <div id=div2 style="OVERFLOW: scroll; WIDTH: 100%; HEIGHT: 100%">
    <%
      if (menuTree.size() > 0)
      {
        int nTreeLevel = 0;
        int nLevelDif = 0;
        int nTopLevel = 0;
        int nEndLevel = 0;
        String strIMG = "TreeAdd.gif";
        
        for (int i = 0; i < menuTree.size(); i++)
        {
          HashMap tmpMenu = (HashMap)menuTree.get(i);
          
          int nNext = ((Integer)tmpMenu.get("next")).intValue();
          String strLevelCode = (String)tmpMenu.get("levelcode");
          nTreeLevel = ((Integer)tmpMenu.get("grade")).intValue() + nLevelDif;
          
          if (((Boolean)tmpMenu.get("ismin")).booleanValue())
          { strIMG = "TreeSub.gif"; }
          else
          { strIMG = "TreeAdd.gif"; }
          
          for (int j = 0;j <= -nNext; j++)
          {
            if (i != 0)
            {
    %>
                </div>                   
              </td></tr>               
            </table>
    <%
            }
          }
          
          if (((Boolean)tmpMenu.get("ismax")).booleanValue())
          {
            nTreeLevel = 1;
            nTopLevel = ((Integer)tmpMenu.get("grade")).intValue();
            nLevelDif = ((Integer)tmpMenu.get("grade")).intValue() - 1;
    %>
          <table cellspacing="0" width="100%">     
            <tr><td class="TreeClass1">
              <a href="javascript:void(0)" <% if (!((Boolean)tmpMenu.get("ismin")).booleanValue()) { %>onClick="expandIt(frm,'KB<%=JspHelper.filterNull( strLevelCode )%>','../../images/<%= strLanguageCode %>/'); return false"<% } %>><img name="KB<%=JspHelper.filterNull( strLevelCode )%>wj" src="../../images/<%= strLanguageCode %>/<%=JspHelper.filterNull( strIMG )%>" height="11" border="0" ></a>
              <a href="javascript:void(0)"><%=JspHelper.filterNull( tmpMenu.get("menuname") )%></a>
              <div class="child<%=JspHelper.filterNull( strLevelCode )%>" id="KB<%=JspHelper.filterNull( strLevelCode )%>Child" style="display:none">
    <%
          }
          
          if (!((Boolean)tmpMenu.get("ismax")).booleanValue() && !((Boolean)tmpMenu.get("ismin")).booleanValue())
          {
    %>
          <table cellspacing="0" width="100%">     
            <tr><td class="TreeClass<%=JspHelper.filterNull( nTreeLevel )%>">
              <a href="#" onClick="expandIt(frm,'KB<%=JspHelper.filterNull( strLevelCode )%>','../../images/<%= strLanguageCode %>/'); return false"><img src="../../images/<%= strLanguageCode %>/<%=JspHelper.filterNull( strIMG )%>" width="11" height="11" name="KB<%=JspHelper.filterNull( strLevelCode )%>wj" border="0"></a>
              <a href="javascript:void(0)"><%=JspHelper.filterNull( tmpMenu.get("menuname") )%></a>
              <div class="child<%=JspHelper.filterNull( strLevelCode )%>" id="KB<%=JspHelper.filterNull( strLevelCode )%>Child" style="display:none">
    <%
          }
          
          if (!((Boolean)tmpMenu.get("ismax")).booleanValue() && ((Boolean)tmpMenu.get("ismin")).booleanValue())
          {
    %>
          <table cellspacing="0" width="100%">     
            <tr><td class="TreeClass<%=JspHelper.filterNull( nTreeLevel )%>">
              <a href="javascript:void(0)"><img src="../../images/<%= strLanguageCode %>/<%=JspHelper.filterNull( strIMG )%>" width="11" height="11" name="KB<%=JspHelper.filterNull( strLevelCode )%>wj" border="0"></a>
              <a href="javascript:parent.rightFrame.addToFavorite('<%=JspHelper.filterNull( tmpMenu.get("privilegecode") )%>')"><%=JspHelper.filterNull( tmpMenu.get("menuname") )%></a>
              <div>
    <%
          }
          
          nEndLevel = ((Integer)tmpMenu.get("grade")).intValue();
        }
        
        for (int j = 0; j <= nEndLevel - nTopLevel; j++)
        {
    %>
            </div>
          </td></tr>               
        </table>
    <%
        }
      }
    %>
    </div>
  </td></tr>
  <tr> 
    <td class="td-listrom">&nbsp;</td>
  </tr>
</table>

<table border="0" cellspacing="1" width="100%">
  <tr> 
    <td class="td_center">&nbsp;</td>
  </tr>
</table>
</form>
</body>
</html>
